<?php

class Mail{
	
	public $id;
	public $subject;
	public $destination;
	public $body;
	public $priority;
	
	function __construct($id = NULL, $subject = NULL, $destination = NULL, $body = NULL, $priority = NULL){
		$this->id = $id;
		$this->subject = $subject;
		if($this->validateMailAdress($destination)){
			$this->destination = $destination;
		}else{
			$this->destination = FALSE;
		}
		$this->body = $body;
		$this->priority = $priority;
	}
	
	function setId($id){
		$this->id = $id;
	}
	
	function setSubject($subject){
		$this->subject = $subject;
	}
	
	function setDestination($destination){
		$this->destination = $destination;
	}
	
	function setBody($body){
		$this->body = $body;
	}
	
	function setPriority($priority){
		$this->priority = $priority;
	}
	
	function getId(){
		return $this->id;
	}
	
	function getSubject(){
		return $this->subject;
	}
	
	function getDestination(){
		return $this->destination;
	}
	
	function getBody(){
		return $this->body;
	}
	
	function getPriority(){
		return $this->priority;
	}
	
	function validateMailAdress($mailAddress){
		if(preg_match('^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[_a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$', $mailAddress)){
			return TRUE;
		}else{
			return FALSE;
		}
	}
}